<?php

namespace Common;

use Think\Controller;
use Common\Model\UserCarModel;

Class CommonCarController extends Controller{

	public $userCar;	//120端用户模型

	public function __construct(){
		parent::__construct();

		//检查token & 保存token&用户信息
		$this->checkToken();
	}

	private function checkToken(){
		$token = I('param.token');
		if(empty($token)){
			$this->ajaxReturn(['status'=>401,'error_info'=>'用户未登陆，请登陆']);
		}

		$userCarModel = new UserCarModel;
		$res = $userCarModel->where(['token'=>$token])->find();
		if($res){
			$this->userCar = $userCarModel;
		}else{
			$this->ajaxReturn(['status'=>401,'error_info'=>'用户登陆信息不正确，请重新登陆']);
		}
	}
	
}

